
class MinStack {
public:
    MinStack() {

    }
    
    void push(int val) {
        st.push(val);
        if(minstack.empty()||val<=minstack.top())
        {
            minstack.push(val);
        }
    }
    
    void pop() {
        if(minstack.top()==st.top())
        {
            minstack.pop();
        }
        st.pop();
    }
    
    int top() {
        return st.top();
    }
    
    int getMin() {
        return minstack.top();
    }
    stack<int> st;
    stack<int> minstack;
};